Speaker 2 Click
Speaker 2 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.
Click Library
- Author : Stefan Filipovic
- Date : Nov 2024.
- Type : SPI type
Software Support
Example Description
This example demonstrates the use of the Speaker 2 Click board. It initializes the board and plays predefined voice messages or sound effects through the speaker module. Supported voices include numbers (ONE to SIX) and sound effects like FAST BEEP.
Example Libraries
- MikroSDK.Board
- MikroSDK.Log
- Click.Speaker2
Example Key Functions
- speaker2_cfg_setup Config Object Initialization function.
void speaker2_cfg_setup(speaker2_cfg_t *cfg)
Speaker 2 configuration object setup function.
Speaker 2 Click configuration object.
Definition speaker2.h:337
- speaker2_init Initialization function.
err_t speaker2_init(speaker2_t *ctx, speaker2_cfg_t *cfg)
Speaker 2 initialization function.
Speaker 2 Click context object.
Definition speaker2.h:312
- speaker2_default_cfg Click Default Configuration function.
err_t speaker2_default_cfg(speaker2_t *ctx)
Speaker 2 default configuration function.
- speaker2_play_voice This function plays a voice at the specified index.
err_t speaker2_play_voice(speaker2_t *ctx, uint16_t index)
Speaker 2 play voice function.
- speaker2_play_macro This function executes a macro command at the specified index.
err_t speaker2_play_macro(speaker2_t *ctx, uint16_t index)
Speaker 2 play macro function.
- speaker2_play_voice_loop This function plays a voice in a loop for a specified number of iterations.
err_t speaker2_play_voice_loop(speaker2_t *ctx, uint16_t index, uint16_t loop_cnt)
Speaker 2 play voice loop function.
Application Init
Initializes the logger module, configures the Speaker 2 Click board, and applies the default settings to reset the device, power it up, verify communication, and load an example audio project into the device memory.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
if ( SPI_MASTER_ERROR ==
speaker2_init( &speaker2, &speaker2_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
#define SPEAKER2_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition speaker2.h:282
void application_init(void)
Definition main.c:36
#define MIKROBUS_POSITION_SPEAKER2
Definition main.c:30
@ SPEAKER2_ERROR
Definition speaker2.h:363
Application Task
Sequentially plays predefined voice messages and sound effects from the Speaker 2 Click board while logging the playback status (DONE or ERROR) for each sound.
{
log_printf ( &logger, " Playing voice ONE: %s\r\n\n", ( char * )
log_printf ( &logger, " Playing voice TWO: %s\r\n\n", ( char * )
log_printf ( &logger, " Playing voice THREE: %s\r\n\n", ( char * )
log_printf ( &logger, " Playing voice FOUR: %s\r\n\n", ( char * )
log_printf ( &logger, " Playing voice FIVE: %s\r\n\n", ( char * )
log_printf ( &logger, " Playing voice SIX: %s\r\n\n", ( char * )
log_printf ( &logger, " Playing voice FAST BEEP: %s\r\n\n", ( char * )
}
#define SPEAKER2_VP10_TWO
Definition speaker2.h:229
#define SPEAKER2_VP14_SIX
Definition speaker2.h:233
#define SPEAKER2_VP12_FOUR
Definition speaker2.h:231
#define SPEAKER2_VP15_FAST_BEEP
Definition speaker2.h:234
#define SPEAKER2_VP9_ONE
Definition speaker2.h:228
#define SPEAKER2_VP13_FIVE
Definition speaker2.h:232
#define SPEAKER2_VP11_THREE
Definition speaker2.h:230
void application_task(void)
Definition main.c:72
@ SPEAKER2_OK
Definition speaker2.h:362
Application Output
This Click board can be interfaced and monitored in two ways:
- Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
- UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.
Additional Notes and Information
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.